<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_warehouse.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%@ page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@page import="com.lmpop.trade.ts_area.*" %>
<%@page import="com.lmpop.trade.ts_category.*" %>
<%@page import="com.lmpop.trade.ti_tradestate.*" %>

<%
	Ti_tradestateInfo tadestate_info = new Ti_tradestateInfo();
	request.setCharacterEncoding("UTF-8");
	Tb_commparaInfo tb_commparaInfo = new Tb_commparaInfo();
	String state = tb_commparaInfo.getSelectItem("39","");   
	Ts_categoryInfo classBean = new Ts_categoryInfo();
	Ts_areaInfo areaBean = new Ts_areaInfo(); 
	
	Map ti_warehouse = new Hashtable();
	String s_cust_name = "";
	if(request.getParameter("s_cust_name")!=null && !request.getParameter("s_cust_name").equals("")){
		s_cust_name = request.getParameter("s_cust_name");
		ti_warehouse.put("cust_name",s_cust_name);
	}
	String s_title = "";
	if(request.getParameter("s_title")!=null && !request.getParameter("s_title").equals("")){
		s_title = request.getParameter("s_title");
		ti_warehouse.put("title",s_title);
	}
	String s_area_attr = "";
	if(request.getParameter("s_area_attr")!=null && !request.getParameter("s_area_attr").equals("")){
		s_area_attr = request.getParameter("s_area_attr");
		ti_warehouse.put("area_attr",s_area_attr);
	}
	String s_price_start = "";
	if(request.getParameter("s_price_start")!=null && !request.getParameter("s_price_start").equals("")){
		s_price_start = request.getParameter("s_price_start");
		ti_warehouse.put("price_start",s_price_start);
	}	
	String s_price_end = "";
	if(request.getParameter("s_price_end")!=null && !request.getParameter("s_price_end").equals("")){
		s_price_end = request.getParameter("s_price_end");
		ti_warehouse.put("price_end",s_price_end);
	}		
	ti_warehouse.put("m_state","1");
	Ti_warehouseInfo ti_warehouseInfo = new Ti_warehouseInfo();
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_warehouseInfo.getListByPage(ti_warehouse,Integer.parseInt(iStart),limit);
	int counter = ti_warehouseInfo.getCountByObj(ti_warehouse);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?iStart=",Integer.parseInt(iStart),limit);
%>
<html>
  <head>
    
    <title>仓库厂房管理</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_areaInfo.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>	
	<script type="text/javascript" src="/js/commen.js"></script>
	<script type="text/javascript" src="js_commen.js"></script>
	<script type="text/javascript" src="searcher.js"></script>
	
	
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>仓库厂房管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<!--
	<table width="100%" align="center" cellpadding="0" cellspacing="0" class="dl_so">
        <tr>
          <td width="9%" align="center"><img src="/program/admin/index/images/ban_01.gif" /></td>
          <td width="91%" align="left">
		  <h4>-----------------</h4>
		  <span>1----------------。</span><br/>
		  <span>2----------------。</span>
		  </td>
        </tr>
      </table>
      <br/>
	  -->
	  
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left">	
				地区: 
				<select name="province" id="province" onclick="setCitys(this.value)">
					<option value="">省份</option> 
				</select>

				<select name="eparchy_code" id="eparchy_code" onclick="setAreas(this.value)">
					<option value="">地级市</option> 
				 </select>
				<select name="city_code" id="city_code" >
					<option value="">市、县级市、县</option> 
				</select>				
				<input name="s_area_attr" id="s_area_attr" type="hidden" />
				标题:<input name="s_title" type="text" />
				会员名称:<input name="s_cust_name" type="text" /><br/>			
				价格区间:<input name="s_price_start" type="text" />-<input name="s_price_end" type="text" />	
				<input name="searchInfo" type="button" value="查询" onclick="searcherForm();"/>	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<select name="up_operating" id="up_operating" onchange="changeTime()">
				  	<option value="">请选择...</option>	
					<option value="-">删除</option>	
					<option value="c">启用</option>
					<option value="d">禁用</option>
					<option value="ship_none">未开始</option>	
					<option value="ship_start">进行中</option>	
					<option value="ship_end">已完成</option>						
				  	<%=state%>
				</select>	
				<div id="b_g" style="display:none">
				开始时间:<input type="text" name="s_start_date" id="s_start_date" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'s_end_date\',{d:-1})}',readOnly:true})" size="15"  width="150px" />
				结束时间:<input type="text" name="s_end_date" id="s_end_date" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'s_start_date\',{d:1})}',readOnly:true})" size="15" width="150px" />
				</div>
				<input type="button" name="delInfo" onclick="operateInfo('up')" value="确定"  class="buttab" />
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
		  	<th>标题</th>
			
		  	<th>会员名称</th>
		  	
		  	<th>状态</th>
		  	
		  	<th>所在区域</th>

		  	<th>价格</th>
			
			<th>交易状态</th>
		  	
		  	<th>创建时间</th>
		  	

	  		<th width="10%">操作</th>
		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String house_id="",cust_id="",state_code="",title="",biz_type="",area_attr="",address="",area="",house_type="",price="",end_date="",in_date="",user_id="",remark="";
	String cust_name = "";
	 String e = "",f = "",g ="";
	if(map.get("cust_name")!=null) cust_name = map.get("cust_name").toString();
	if(map.get("house_id")!=null) house_id = map.get("house_id").toString();
  	if(map.get("cust_id")!=null) cust_id = map.get("cust_id").toString();
  	if(map.get("state_code")!=null) state_code = map.get("state_code").toString();
  	if(map.get("title")!=null) title = map.get("title").toString();
  	if(map.get("biz_type")!=null) biz_type = map.get("biz_type").toString();
  	if(map.get("area_attr")!=null) area_attr = map.get("area_attr").toString();
  	if(map.get("address")!=null) address = map.get("address").toString();
  	if(map.get("area")!=null) area = map.get("area").toString();
  	if(map.get("house_type")!=null) house_type = map.get("house_type").toString();
  	if(map.get("price")!=null) price = map.get("price").toString();
  	if(map.get("end_date")!=null) end_date = map.get("end_date").toString();
if(end_date.length()>19)end_date=end_date.substring(0,19);
  	if(map.get("in_date")!=null) in_date = map.get("in_date").toString();
if(in_date.length()>19)in_date=in_date.substring(0,19);
  	if(map.get("user_id")!=null) user_id = map.get("user_id").toString();
  	if(map.get("remark")!=null) remark = map.get("remark").toString();

		String areaAttr = "";
			
		if (map.get("area_attr") != null) {
		area_attr = map.get("area_attr").toString();
		String areaArr[] = area_attr.split("\\|");
		for( int k = 0; k < areaArr.length; k++ ){
			areaAttr = areaAttr + " &nbsp; " + "<a href='index.jsp?s_area_attr="+areaArr[k] +"'>" + areaBean.getAreaNameById( areaArr[k]);
		}
	}
	
					if(map.get("e")!=null) e = map.get("e").toString();
					if(map.get("f")!=null) f = map.get("f").toString();
					if(map.get("g")!=null) g = map.get("g").toString();	
					
					
						String trade_state="";
						String trade_state_string="";
						trade_state = tadestate_info.getTradeStateByID(house_id);
						
						if(trade_state.equals("1")){
							trade_state_string="<font color='#666666'>交易未开始</font>";
						} else if(trade_state.equals("2")){
							trade_state_string="<font color='GREEN'>交易进行中</font>";
						} else if(trade_state.equals("3")){
							trade_state_string="<font color='RED'>交易已完成</font>";
						}						
		  %>

		  
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=house_id %>" /></td>
			<td><a href="updateInfo.jsp?house_id=<%=house_id %>"><%=title%></a></td>
			
		  	<td><%=cust_name%></td>
		  	
		  	<td>
				<span class="<%if(state_code.indexOf("c")>-1)out.print("blueon"); else out.print("blueoff");%>">启用</span> 
	            <span class="<%if(state_code.indexOf("d")>-1)out.print("blueon"); else out.print("blueoff");%>">禁用</span> 
				
	            <span class="<%if(!e.equals(""))out.print("blueon"); else out.print("blueoff");%>">推荐</span>
	            <span class="<%if(!f.equals(""))out.print("blueon"); else out.print("blueoff");%>">置顶</span>
	            <span class="<%if(!g.equals(""))out.print("blueon"); else out.print("blueoff");%>">头条</span> 
	           			
			</td>
		  	
		  	
		  	<td><%=areaAttr%></td>
		  	
		  	<td><%=price%>&nbsp;元</td>
			
			<td><%=trade_state_string%></td>
		  	
		  	<td><%=in_date%></td>
		  	
			<td width="10%"><a href="/program/admin/tradeinfo/tradeIndex.jsp?info_id=<%=house_id %>"><img src="/program/admin/images/view.gif" title="查看" /></a>&nbsp;
			<a href="updateInfo.jsp?house_id=<%=house_id %>"><img src="/program/admin/images/edit.gif" title="修改" /></a>&nbsp;
	  		<a href="javascript:deleteOneInfo('<%=house_id%>','5732');"><img src="/program/admin/images/delete.gif" title="删除" /></a></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="state_code" id="state_code" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="5732" />
	  </form>
</body>

</html>
